package com.example.demo.service.impl;

import com.example.common.utils.TrimSpaceUtil;
import com.example.demo.domain.RecommendInfo;
import com.example.demo.domain.RecommendSearch;
import com.example.demo.mapper.RecommendMapper;
import com.example.demo.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RecommendServiceImpl implements RecommendService {
    @Autowired
    private RecommendMapper recommendMapper;

    @Override
    public List<RecommendInfo> selectRecommendSpotInfo(String level, String spotName) {
        List<RecommendInfo> recommendInfos = recommendMapper.selectRecommendSpotInfo(level, spotName);
        List<RecommendInfo> result = new ArrayList<>();
        for (RecommendInfo recommendInfo : recommendInfos) {
            //字符过滤
            RecommendInfo o = (RecommendInfo) TrimSpaceUtil.replaceBlankSpace(recommendInfo);
            result.add(o);
        }
        return result;
    }

    /**
     * 智能推荐
     */
    @Override
    public List<RecommendInfo> selectAIRecommendSpotInfo(RecommendSearch recommendSearch) {
        List<RecommendInfo> recommendInfos = recommendMapper.selectAIRecommendSpotInfo(recommendSearch);
        List<RecommendInfo> result = new ArrayList<>();
        for (RecommendInfo recommendInfo : recommendInfos) {
            //字符过滤
            RecommendInfo o = (RecommendInfo) TrimSpaceUtil.replaceBlankSpace(recommendInfo);
            result.add(o);
        }
        return result;
    }

}
